<?php

session_start();

require_once("class/accounts.class.php");
require_once("inc/properties.php");


?>

<div class="listing-container">

<?php //var_dump($_SESSION); ?>

<table class="accounts-listing" border="0" cellspacing="0">

 <tr>
  <th width="160px">Last Name</th>
  <th width="160px">First Name</th>
  <th width="300px">E-mail</th>
  <th width="160px">Role</th>
  <th width="44px" colspan="2">Edit</th>
 </tr>

 <?php 
  
  $account_row = NULL;
  $user_accounts = accounts::getInstance()->get_accounts();
  if ($user_accounts) {
   while (($account_row = mysql_fetch_array($user_accounts, MYSQL_ASSOC)) != NULL) {
 ?>
 
 <tr id="account_<?php echo $account_row['account_id'] ?>">
  <td><?php echo $account_row['lastname'] ?></td>
  <td><?php echo $account_row['firstname'] ?></td>
  <td><?php echo $account_row['email'] ?></td>
  <td><?php
    switch ($account_row['permission']) {
        case STUDENT_ROLE:
            echo "Student";
            break;
        case TUTOR_ROLE:
            echo "Tutor";
            break;
        case ADMIN_ROLE:
            echo "Administrator";
            break;
        default:
            break;
    }?></td>
    <td><a href="#" title="Edit" class="edit"><img src="img/pencil.png" alt="Edit"></a></td>
    <td><a href="#" title="Delete" class="del"><img src="img/cross.png" alt="Delete"></a></td>
    
 </tr>
 
 <?php 
  }
 }
 ?>
 
</table>

</div>
